-
Notifications
You must be signed in to change notification settings - Fork 9
Tracking pull request to merge release-1.32.0 to main #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
* sftp automation * some fixes and changes
|
| pkey_file = get_minio_object(settings.SSH_PKEY_FILENAME) | ||
| pkey = paramiko.RSAKey.from_private_key(io.StringIO(pkey_file.data.decode("utf-8"))) | ||
| client = paramiko.SSHClient() | ||
| client.set_missing_host_key_policy(paramiko.AutoAddPolicy) |
Check failure
Code scanning / CodeQL
Accepting unknown SSH host keys when using Paramiko High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix this issue, you should change the missing host key policy in the get_ssh_client() function from paramiko.AutoAddPolicy to paramiko.RejectPolicy. The RejectPolicy will refuse connection if the host key is not present in the known hosts file, ensuring host authenticity and protecting against man-in-the-middle exploits. This fix should be implemented by changing line 157 in django/api/services/cra.py so that it reads client.set_missing_host_key_policy(paramiko.RejectPolicy).
If this change causes exceptions upon connecting to new servers, you'll need to ensure that host keys are preloaded into the system's known hosts (or manually added via Paramiko's load_system_host_keys or load_host_keys methods). However, based solely on the code provided, only the policy line needs to be updated.
-
Copy modified line R157
| @@ -154,7 +154,7 @@ | ||
| pkey_file = get_minio_object(settings.SSH_PKEY_FILENAME) | ||
| pkey = paramiko.RSAKey.from_private_key(io.StringIO(pkey_file.data.decode("utf-8"))) | ||
| client = paramiko.SSHClient() | ||
| client.set_missing_host_key_policy(paramiko.AutoAddPolicy) | ||
| client.set_missing_host_key_policy(paramiko.RejectPolicy) | ||
| client.connect( | ||
| settings.CRA_SFTP_HOST, | ||
| port=int(settings.CRA_SFTP_PORT), |



No description provided.